package org.smart4j.chapter2.service;

import org.smart4j.chapter2.model.Customer;
import org.smart4j.chapter2.util.PropsUtil;

import java.util.List;
import java.util.Map;
import java.util.Properties;

import static com.sun.xml.internal.ws.spi.db.BindingContextFactory.LOGGER;

/**
 * Created by LIFR on 2017/3/17.
 */
public class CustomerService {

    private static final String DRIVER;
    private static final String URL;
    private static final String USERNAME;
    private static final String PASSWORD;

    static {
        Properties conf = PropsUtil.loadProps("config.properties");
        DRIVER=conf.getProperty("jdbc.driver");
        URL=conf.getProperty("jdbc.url");
        USERNAME=conf.getProperty("jdbc.username");
        PASSWORD=conf.getProperty("jdbc.password");

        try{
            Class.forName(DRIVER);
        }catch (ClassNotFoundException e){
            LOGGER.error("can not load jdbc driver",e);
        }
    }

    public List<Customer> getCustomerList(String keyword){
        //todo
        return null;
    }

    public Customer getCustomer(long id){
        //todo
        return null;
    }

    public boolean createCustomer(Map<String,Object> fieldMap){
        //todo
        return false;
    }

    public boolean updateCustomer(long id,Map<String,Object> fieldMap){
        //todo
        return false;
    }

    public boolean deleteCustomer(long id){
        //todo
        return false;
    }
}
